#ifndef _YEP_VIDEO_TILESET_HPP
#define _YEP_VIDEO_TILESET_HPP

#include "../common.hpp"
#include "image.hpp"

namespace yep
{
// Foward declaration.
class Texture;

/**
 * @brief A tileset.
 **/
class Tileset
{
public:

	/**
	 * @brief Default constructor
	 **/
	Tileset();

	/**
	 * @brief Creates a tileset based on the giver attributes
	 **/
	Tileset(Texture &texture, Uint8 tileWidth, Uint8 tileHeight);

	/**
	 * @brief Destructor
	 **/
	~Tileset();

	/**
	 * @brief Draw a tile on canvas
	 **/
	void draw(Canvas &dst, const Vector2 &position, int index);

	/**
	 * @brief Return the number of tiles.
	 **/
	unsigned getSize();

	/**
	 * @brief Returns the texture
	 **/
	Texture &getTexture() const
	{
		return *texture;
	}

	/**
	 * @brief Changes the texture
	 **/
	void setTexture(Texture &value)
	{
		texture = &value;
		evaluateSize();
	}

	/**
	 * @brief Returns the tileWidth
	 **/
	Uint8 getTileWidth() const
	{
		return tileWidth;
	}

	/**
	 * @brief Changes the tileWidth
	 **/
	void setTileWidth(Uint8 value)
	{
		tileWidth = value;
		evaluateSize();
	}

	/**
	 * @brief Returns the tileHeight
	 **/
	Uint8 getTileHeight() const
	{
		return tileHeight;
	}

	/**
	 * @brief Changes the tileHeight
	 **/
	void setTileHeight(Uint8 value)
	{
		tileHeight = value;
		evaluateSize();
	}
private:
	Texture *texture;
	Uint8 tileWidth;
	Uint8 tileHeight;
	unsigned size;
	unsigned rowSize;

	void evaluateSize();
};

}

#endif // _YEP_VIDEO_TILESET_HPP
